package uz.edo.app.admin;

import org.apache.wicket.RestartResponseAtInterceptPageException;
import org.apache.wicket.markup.html.WebPage;
import uz.edo.app.admin.core.AdminConstants;
import uz.edo.app.admin.core.AdminSession;
import uz.edo.app.admin.core.header.AdminHeader;
import uz.edo.db.bean.User;
import uz.edo.db.bean.Role;

/**
 * Created by IntelliJ IDEA.
 * User: said
 * Date: 1/16/12
 * Time: 12:06 PM
 * To change this template use File | Settings | File Templates.
 */
public class AdminPage extends WebPage implements AdminConstants{

    private User user;

    protected AdminPage() {
        AdminSession session = (AdminSession)getSession();
        if (!session.isLoged())
            throw new RestartResponseAtInterceptPageException(Login.class);
        else{
            user = session.getUser();
        }
        add(new AdminHeader("adminHeader"));
    }

    public User getUser() {
        return user;
    }

    public Role getRole(String roleName){
        return  user.getRole(roleName);
    }

    public boolean isPrivileged(String privilege){
        return user.isPrivileged(privilege);
    }
}
